//
//  MXCollocationContentCollectionViewCell.m
//  MXの衣柜
//
//  Created by 马霄 on 15/8/6.
//  Copyright (c) 2015年 霄 马. All rights reserved.
//

#import "MXCollocationContentCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation MXCollocationContentCollectionViewCell
- (void)dealloc
{
    [_modelS release];
    [_mainImage release];
    [_titleLabel release];
    [_detailLabel release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.mainImage = [[[UIImageView alloc] init] autorelease];
        [self.contentView addSubview:self.mainImage];
        
        self.titleLabel = [[[UILabel alloc] init] autorelease];
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.titleLabel];
        
        self.detailLabel = [[[UILabel alloc] init] autorelease];
        self.detailLabel.font = [UIFont systemFontOfSize:12];
        self.detailLabel.textAlignment = NSTextAlignmentCenter;
        [self.detailLabel setTextColor:[UIColor blueColor]];
        [self.contentView addSubview:self.detailLabel];
        
        
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat WID = self.contentView.frame.size.width;
    CGFloat mainImageX = 0;
    CGFloat mainImageY = 0;
    CGFloat mainImageW = WID;
    CGFloat mainImageH = WID + HEIGHTPRO * 60;
    self.mainImage.frame = CGRectMake(mainImageX, mainImageY, mainImageW, mainImageH);
    //  flowLayout.itemSize = CGSizeMake(170, 240);

    self.titleLabel.frame = CGRectMake(0, mainImageH, WID, HEIGHTPRO * 40);
    
    self.detailLabel.frame = CGRectMake(0, mainImageH + HEIGHTPRO * 40, WID, HEIGHTPRO * 30);
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(WIDTHPRO * 20, WID + HEIGHTPRO * 99, self.titleLabel.frame.size.width - WIDTHPRO * 40, HEIGHTPRO * 1)];
    line.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:line];
    
    

}
-(void)GetInfo:(MXCollocationContentModel *)model
{
    if (_modelS != model) {
        
        [_modelS release];
        
        _modelS = [model retain];
    }
    
    [self.mainImage sd_setImageWithURL:[NSURL URLWithString:model.big_image] placeholderImage:[UIImage imageNamed:@"plaseholder"]];
    
    self.titleLabel.text = model.info;
    
    self.detailLabel.text = model.collocation_type;
    

    
}
@end
